
$(document).ready(function () {

    // 去除虚线框（会影响效率）
    //$("a").on('focus', function () { $(this).blur(); });


    //$('.file input[type=file]').change(function (e) {
    //    $(this).siblings('.text').text($(this).val());
    //});

    //if (!-[1, ]) {
    //    $('input[type=radio]').bind('click', function () {
    //        var name = $(this).attr('name');
    //        $('input[type=radio]["name="' + name + ']').removeClass('checked');
    //        if ($(this).prop('checked')) {
    //            $(this).addClass('checked');
    //        }
    //    });
    //}
    //if (!!!$('.opt-panel').size() && !!!$('.system-switch').size()) {
    //    $(document).click(function (e) {
    //        $(top.window.document).find('.opt-panel').hide().end().find('.system-switch').hide();
    //        $(top.window.document).find('.more-info').removeClass('active').end().find('.logo-icon').removeClass('active');
    //    });
    //}

    //if (!!!$('.more-bab-list').size()) {
    //    $(document).click(function (e) {
    //        $(top.window.document).find('iframe').contents().find('.more-bab-list').hide();
    //        $(top.window.document).find('iframe').contents().find('.tab-more').removeClass('active');
    //    });
    //}

    $(".tblForm tr").each(function () {
        $(this).children("td[class!='tdFormLeft']").attr("style", "width:210px;");
        $(this).children("td[colspan]").attr("style", "width:85%;");
    })
});

function trColor() {
    $(".tablelist tbody").find("tr:odd").css("backgroundColor", "#eff6fa");
}

function hideElement(currentElement, targetElement, fn) {
    if (!$.isArray(targetElement)) {
        targetElement = [targetElement];
    }
    $(document).on("click.hideElement", function (e) {
        var len = 0, $target = $(e.target);
        for (var i = 0, length = targetElement.length; i < length; i++) {
            $.each(targetElement[i], function (j, n) {
                if ($target.is($(n)) || $.contains($(n)[0], $target[0])) {
                    len++;
                }
            });
        }
        if ($.contains(currentElement[0], $target[0])) {
            len = 1;
        }
        if (len == 0) {
            currentElement.hide();
            fn && fn(currentElement, targetElement);
        }
    });
};

function readOnlyAll(element) {
    $(element).each(function (el, i) {
        $(this).attr("disabled", true);
    });
}


function resize(resizeHandle) {
    var d = document.documentElement;
    var timer;//避免resize触发多次,影响性能
    var width = d.clientWidth, height = d.clientHeight;
    $(top.window).on('resize', function (e) {
        if ((width != d.clientWidth || height != d.clientHeight)) {
            width = d.clientWidth, height = d.clientHeight;
            if (timer) { clearTimeout(timer); }
            timer = setTimeout(function () {
                resizeHandle();
            }, 10);
        }
    });

}





function checkEmpty(v) {
    if (v == "") return true;
    return false;
}
// 选择 取消选择所有记录
function selectAll() {
    var o = document.getElementById("ckall");

    var obj = document.getElementsByTagName("input"); //返回标签名为"input"的对象数组
    var ids = "";
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].type == "checkbox" && obj[i].name == 'ckid') obj[i].checked = o.checked;
    }
}

//获取当前选择的记录id
function getSelectIds() {
    var obj = document.getElementsByTagName("input"); //返回标签名为"input"的对象数组
    var ids = "";
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].type == "checkbox" && obj[i].checked == true && obj[i].name == 'ckid') ids += "," + obj[i].value;
    }
    if (ids.length > 1) {
        ids = ids.substring(1, ids.length);
        return ids;
    } else {
        return "";
    }
    //alert(ids);
}
//获取当前选择的记录id,只获取第一个
function getSelectId() {
    var obj = document.getElementsByTagName("input"); //返回标签名为"input"的对象数组
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].type == "checkbox" && obj[i].checked == true && obj[i].name == 'ckid')
            return obj[i].value;
    }
    return "";
}


//获取当前选择的记录条数
function getSelectCount() {
    var obj = document.getElementsByTagName("input"); //返回标签名为"input"的对象数组
    var n = 0;
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].type == "checkbox" && obj[i].checked == true && obj[i].name == 'ckid') n++;
    }
    return n;
}


function selectAllByPara(allCkName, detailCkName) {
    var o = document.getElementById(allCkName);

    var obj = document.getElementsByTagName("input"); //返回标签名为"input"的对象数组
    var ids = "";
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].type == "checkbox" && obj[i].name == detailCkName) obj[i].checked = o.checked;
    }
}

